// 流程分组管理接口
import { ajaxService } from '@/utils/request';
import {
  FlowGroup,
  FlowGroupParams,
  FlowGroupAndProcessParams,
  FowSpecifiedGroupProcess
} from './type';

const env = import.meta.env;
const baseURL = env.VITE_APP_BASE_URL;
/**
 *
 * @param data 新增流程分组
 * @returns
 */
export async function AddFlowProcessGroups(data: FlowGroup) {
  return ajaxService({
    url: '/flow/process/groups',
    method: 'post',
    baseURL,
    data
  });
}
/**
 * 获取流程分组列表
 * @param params
 * @returns
 */
export async function getFlowProcessGroupsList(params: FlowGroupParams) {
  return ajaxService<{ content: any }>({
    url: '/flow/process/groups/page',
    method: 'get',
    baseURL,
    params
  });
}
/**
 * 获取所有流程分组
 * @returns
 */
export async function getFlowProcessGroupsAll() {
  return ajaxService<any>({
    url: '/platform_ccc/FlowProcessGroups/all',
    method: 'get',
    baseURL
  });
}
export async function getFlowProcessGroupsById(groupCode: string) {
  return ajaxService<{ processGroupsInfo: any }>({
    url: `/flow/process/groups/${groupCode}`,
    method: 'get',
    baseURL
  });
}
/**
 * 获取分组及流程列表
 * @returns
 */
export async function getFlowGroupsAndProcessList(
  params: FlowGroupAndProcessParams
) {
  return ajaxService<any>({
    url: `/flow/process/groups/all/list`,
    method: 'get',
    baseURL,
    params
  });
}
/**
 * 获取分组及流程列表（新）
 * @returns
 */
export async function getSpecifiedGroupProcessList(
  params: FowSpecifiedGroupProcess
) {
  return ajaxService<any>({
    url: `/flow/specified/group/process/list`,
    method: 'get',
    baseURL,
    params
  });
}
/**
 * 编辑流程分组
 * @param params
 * @returns
 */
export async function editFlowProcessGroups(data: FlowGroup) {
  return ajaxService({
    url: '/flow/process/groups',
    method: 'put',
    baseURL,
    data
  });
}
/**
 * 删除流程分组
 * @param params
 * @returns
 */
export async function delFlowProcessGroupsByIds(data: { ids: number[] }) {
  return ajaxService({
    url: `/flow/process/groups`,
    method: 'delete',
    baseURL,
    data
  });
}
/**
 * 流程分组排序
 * @param params
 * @returns
 */
export async function flowOrderSetting(data: any) {
  return ajaxService({
    url: '/flow/order/process/groups',
    method: 'put',
    baseURL,
    data
  });
}
